Answer:

2  4  6  8  10

The loop control variable (the counter) C starts at 2, then the program counts upward by twos until it reaches the ending value of 10.

What STEP Does

Here is the general form of the FOR (again):

FOR counter = startingValue TO endingValue STEP stepSize 
  loopBody
NEXT counter

Here are some rules about how the FOR statement works:

  1. The first time loopBody is executed, counter has the value startingValue.
  2. Each time control hits the NEXT counter statement, counter is changed by stepSize , and control is sent back to the top of the loop.
  3. When counter goes beyond endingValue, the loop ends.
    • If the loop is counting UPWARD, the loop ends as soon as counter IS GREATER THAN endingValue.
    • If the loop is counting DOWNWARD, the loop ends as soon as counter IS LESS THAN endingValue.
  4. If counter is already beyond endingValue before the loop starts, the loopBody will not be executed even once.

As usual, these rules look a lot worse than they really are. A few examples should help. Here is a program that lists out odd numbers. It starts at 1, then goes to 3, then to 5, and so on. The problem is deciding where it stops.

FOR ODD = 1 TO 5 STEP 2
  PRINT ODD;
NEXT ODD
'
END

QUESTION 6:

What will the program print out?